import { BrandInterface } from "./brand";
import { TinyCategoryType } from "./category";
import { SpecsType } from "./property";

// 商品接口
export interface GoodInterface {
    id: string,
    name: string,
    desc: string,
    price: string,
    picture: string,
    discount?: number,
    orderNum?: number,
};

interface SkuInterface {
    price: string,
    oldPrice: string,
    inventory: number,
}

// Detail页面商品sku类型
export interface RawSkuType extends SkuInterface {
    id: string,
    skuCode: string,
    specs: Array<{
        name: string,
        valueName: string,
    }>,
};

// Detail页面XtxSku组件回传的商品sku类型
export interface ComputedSkuType extends SkuInterface {
    skuId: string,
    specsText: string,
};

// Detail页面商品评价信息类型
type EvaluateInfoType = {
    id: string,
    orderInfo: null,
    member: null,
    score: number,
    tags: null,
    content: string,
    pictures: null,
    officialReply: null,
    praiseCount: number,
};

// Detail页面商品详情数据类型
export interface GoodDetailType extends GoodInterface {
    spuCode: string,
    oldPrice: string,
    inventory: number,
    brand: BrandInterface,
    salesCount: number,
    commentCount: number,
    collectCount: number,
    mainVideos: Array<string>,
    videoScale: number,
    mainPictures: Array<string>,
    specs: Array<SpecsType>,
    skus: Array<RawSkuType>,
    categories: Array<TinyCategoryType>,
    details: {
        pictures: Array<string>,
        properties: Array<{ name: string, value: string }>,
    },
    isPreSale: boolean,
    isCollect: null,
    recommends: null,
    userAddresses: null,
    similarProducts: Array<GoodInterface>,
    hotByDay: Array<GoodInterface>,
    evaluationInfo: EvaluateInfoType,
};

// Detail页面热榜数据请求参数类型
export type GoodDetailRankRequestParamsType = {
    id: number,
    type: number,
    limit?: number,
};

// 具有规格的商品类型
export interface SkuGoodInterface {
    skuId: string,
    count: number,
};

// 购物车内商品类型
export interface CartItemType extends SkuGoodInterface {
    id: string,
    name: string,
    picture: string,
    price: string,
    attrsText: string,
    selected?: boolean,
    // specs: Array<string>,
    // nowPrice: string,
    // nowOriginalPrice: string,
    // stock: string,
    // isEffective: boolean,
    // discount: null,
    // isCollet: boolean,
    // postFee: number,
};

// 支付信息商品类型
export type PayInfoGoodType = {
    id: string,
    spuId: string,
    name: string,
    quantity: number,
    image: string,
    realPay: number,
    curPrice: number,
    totalMoney: null,
    properties: Array<{ propertyMainName: string, propertyValueName: string }>,
    attrsText: string,
}